App({
  onLaunch:function(){
    wx.cloud.init({ traceUser:true})
    var that = this;
    wx.onAccelerometerChange(function (e) {
      var timestamp = Date.parse(new Date()) / 1000;
      if (timestamp - that.timestamp>2){
        if (Math.abs(e.x) > 0.7 && Math.abs(e.y) > 0.7) {
          var list = getCurrentPages();
          console.log(list);
          var page = list[list.length - 1];
          if (page.getPre){
            page.getPre();
          }
          that.timestamp = Date.parse(new Date()) / 1000;
        }
      }
    })
  },
  timestamp: Date.parse(new Date()) / 1000,
  showOk:function(str){
    wx.showToast({
      title: str,
      icon: 'success',
      duration: 2000
    })
  },
  alert:function(str){
    wx.showModal({
      title: '温馨提示',
      content: str,
      showCancel:false
    })
  },
  alert_cb: function (str,cb) {
    wx.showModal({
      title: '温馨提示',
      content: str,
      showCancel: false,
      success:cb
    })
  }, showOk_cb: function (str, cb) {
    wx.showToast({
      title: str,
      icon: 'success',
      duration: 2000,
      success:cb
    })
  }
})